import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sudoku/util/image_util.dart';
import 'package:sudoku/util/sukodu/generator.dart';

class LevelDialog extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Material(
      color: Colors.transparent,
      child: Center(
        child: Container(
          width: 526 * 0.6,
          height: 684 * 0.6,
          decoration: BoxDecoration(
              image: DecorationImage(image: AssetImage(getImgPath("panel")))),
          child: Column(
            children: [
              const SizedBox(
                height: 20,
              ),
              const Text(
                "难度等级",
                style: TextStyle(
                    decoration: TextDecoration.none,
                    color: Colors.white,
                    fontFamily: "Han",
                    shadows: [
                      BoxShadow(
                          color: Color(0xFF1B6B65),
                          offset: Offset.zero,
                          blurRadius: 20,
                          spreadRadius: 0)
                    ],
                    fontWeight: FontWeight.w600,
                    fontSize: 20),
              ),
              const SizedBox(
                height: 30,
              ),
              _btnWidget("入门级", () {
                Get.back(result: LEVEL.EASY);
              }),
              const SizedBox(
                height: 10,
              ),
              _btnWidget("中等级", () {
                Get.back(result: LEVEL.MEDIUM);
              }),
              const SizedBox(
                height: 10,
              ),
              _btnWidget("困难级", () {
                Get.back(result: LEVEL.HARD);
              }),
              const SizedBox(
                height: 10,
              ),
              _btnWidget("大师级", () {
                Get.back(result: LEVEL.EXPERT);
              }),
              const Spacer(),
              InkWell(
                onTap: () {
                  Get.back();
                },
                child: loadAssetImage("close", width: 40),
              ),
              const SizedBox(
                height: 40,
              ),
            ],
          ),
        ),
      ),
    );
  }

  Widget _btnWidget(String title, VoidCallback clickCallback) {
    return InkWell(
      onTap: clickCallback,
      child: SizedBox(
        width: 150,
        child: Stack(
          alignment: Alignment.center,
          children: [
            loadAssetImage("btn_bg"),
            Text(
              title,
              style: const TextStyle(
                  color: Colors.white,
                  fontSize: 25,
                  fontFamily: "Han",
                  fontWeight: FontWeight.bold),
            )
          ],
        ),
      ),
    );
  }
}

Future showLevelDialog() {
  return showDialog(
      context: Get.context!,
      builder: (BuildContext context) {
        return LevelDialog();
      });
}
